Export to .xlsx unreadable...except in Word!

Hi Everyone.

I have a script that (used to) export data to an Excel worksheet.  It uses the filename specified/chosen through a GUI and

tacks ".xlsx" on the end.

 

Well, the file is created and written to by the application.  You cannot, however, open it with Excel, as the application complains

the "Excel cannot open the file ''Output.xlsx' because the file format or file extension is invalid."  You can open it with Word 2016

and the text is totally readable.  (??!!!)

This script was last used/modified in 2011.  I believe the DOORS version was 9.1 on that project.

 

Anyone have any idea what debug steps I should take?

 

Thanks,

T Wilk


FormerIBMer - Fri Oct 05 09:49:52 EDT 2018

Re: Export to .xlsx unreadable...except in Word!
PekkaMakinen - Fri Oct 05 10:50:10 EDT 2018

Can you open that file in Notepad? If you can is it a (binary) Excel file or a text file, e.g. CSV (Comma Separated Values)?

Re: Export to .xlsx unreadable...except in Word!
Mike.Scharnow - Fri Oct 05 11:53:46 EDT 2018

Excel allows .xls files to have content that is not exactly "excel", e.g. in some other tool, I create a file with HTML content (table, tr, td), name it .xls and although Excel complains that the content does not match, it will still open the file after asking the user if he is sure about it.

 

With .XLSX, Excel is much stricter. XLSX must have the official structure, i.e. it must be a zipped file with the correct xml files and directories, otherwise it will not be opened.

 

So, in your script, just name your file "output.xls" and you will have, well, less problems :)

 

Edit: it may be that Excel 2007 (or 2003 with compatibility pack) was less strict with the file format. Excel 2010 and future versions may have changed their behaviour